home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / NextAnswers / 1305_NXBrowser_NXGetNamedObject.rtf < prev    next >
Text File  |  1995-06-12  |  2KB  |  56 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fmodern Ohlfs;}
  2. \paperw12940
  3. \paperh12400
  4. \margl120
  5. \margr1000
  6. {\colortbl;\red0\green0\blue0;\red84\green84\blue84;\red83\green83\blue83;\red82\green82\blue82;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs28\fc0\cf0 Q:  I am using the function
  8. \b  NXGetNamedObject
  9. \b0 (const char
  10. \b  
  11. \b0\i * aname
  12. \b\i0 , 
  13. \b0 id
  14. \i  owner
  15. \i0 ) to find the 
  16. \b id 
  17. \b0 of my NXBrowser object.  
  18. \fc1\cf1 My main program containing the
  19. \b  loadNibSection:owner:
  20. \b0  was created by InterfaceBuilder and had NXApp in the 
  21. \b owner:
  22. \b0  argument.  However, passing NXApp as the owner always returns a nil 
  23. \b id
  24. \b0 . What am I doing wrong?\
  25. \
  26. A:  By default, InterfaceBuilder assigns the Application object (NXApp) as the owner of a Window, and a View's Window as the owner of that View.  Since NXBrowser is a subclass of View, you must use the NXBrowser's Window id  instead of NXApp as owner in the function 
  27. \b NXGetNamedObject()
  28. \b0 . \
  29. \
  30. Below is a code snippet for illustration:\
  31. \
  32.  
  33. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f1\fs24\fc1\cf1     id myWindow, myBrowser;\
  34.     \
  35.         /* Get the id for the browser's window */\
  36.     myWindow = NXGetNamedObject("MyWindow", NXApp);\
  37.         /* Get the id of the browser itself */\
  38.     myBrowser = NXGetNamedObject("MyBrowser", myWindow);\
  39.     \
  40.  
  41. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0\cf0 \
  42.  
  43. \f0\fs28 Note that named objects are a big performance loser because of the memory it takes to keep track of all the names of the objects. For this reason, we would recommend that you use 
  44. \b loadNibSection
  45. \b0\i :owner
  46. \b\i0 :withNames:
  47. \b0\i NO
  48. \i0  when loading in nib files.  Try to use outlets instead of named objects whenever possible.\
  49. \
  50.  
  51. \fc1\cf1 QA816\
  52. \
  53. Valid for 2.0, 3.0\
  54. \
  55.  
  56.